#include "stdafx.h"
#include <cstdint>
#include "Auth.h"


float openAnimation = 0.0f;

struct ClosingParticle {
	float x, y;
	float speedX, speedY;
	float alpha;
	bool active;
};

struct Particle {
	float x, y;       // Position of the particle
	float speedY;     // Vertical speed
	float alpha;      // Transparency
};

ClosingParticle closingParticles[40]; // More for smoother explosion
bool particlesExploding = false;

MenuItems_s MenuItems;
bool buttonFinished;
int infoboxCurrentDrawn = 0;
int instructionIndex = 0;
int SelectedPlayer = -1;
int menuOptions = 6;

char* RME_Toggle[0x2] = { "Set", "Take" };
char* RME_Teams[0x2] = { "Enemies", "Friendlies" };

char* RME_GiveWeapons[42] = {
	"AN-94", "M8A1", "FAL OSW", "Type-25", "MTAR", "SMR", "SCAR-H", "SWAT-556",
	"M27", "MP7", "PDW", "Vector", "MSMC", "Chicom CQB", "Skorpion EVO", "Peacekeeper",
	"MK-48", "LSAW", "QBB LSW", "HAMR", "KSG", "R870 MCS", "S12", "M1216", "Ballista",
	"DSR-50", "SVU", "XPR", "Five-Seven", "Tac-45", "B23R", "Executioner", "KAP-40",
	"RPG", "SHAW", "FHJ-18", "Knife", "Riotshield", "Crossbow", "Throwable RC-XD", 
	"Throwable War Machine", "Default Weapon" };

BYTE RME_weaponIndexes[42] = {
	0x30, 0x2C, 0x1C, 0x14, 0x10, 0x28, 0x24, 0x18,
	0x20, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0C,
	0x38, 0x3A, 0x3C, 0x3E, 0x36, 0x34, 0x35, 0x37,
	0x42, 0x41, 0x40, 0x43, 0x4E, 0x4F, 0x50, 0x51,
	0x52, 0x56, 0x54, 0x55, 0x5B, 0x59, 0x5A, 0x6B,
	0x6C, 0x01 };

char* RME_AntiQuit[2] = {
	"Set",
	"Reset"
};

mapNames_s mapNames[15] = {
	"mp_la", "Aftermath",
	"mp_dockside", "Cargo",
	"mp_carrier", "Carrier",
	"mp_drone", "Drone",
	"mp_express", "Express",
	"mp_hijacked", "Hijacked",
	"mp_meltdown", "Meltdown",
	"mp_overflow", "Overflow",
	"mp_nightclub", "Plaza",
	"mp_raid", "Raid",
	"mp_slums", "Slums",
	"mp_village", "Standoff",
	"mp_turbine", "Turbine",
	"mp_socotre", "Yemen",
	"mp_nuketown_2020", "Nuketown 2025"
};

char* DrawingTypes[0x4] = { "2D", "2D Filled", "3D", "Corners" };

int correctSubMenu() {
	switch (MenuItems.submenu) {
	case CLIENT_OPTIONS:
		return CLIENT_LIST;
	case CLIENT_OPTIONS_PAGE_2:
	case CLIENT_OPTIONS_PAGE_3:
	case CLIENT_RME_EXTRAS:
	case RME_PAGE_2:
	case RME_EXTRAS:
	case RME_ALL_CLIENTS:
	case RME_MENU_RENAME_PRESETS:
		return MAIN;
	default:
		return MenuItems.submenu; // This will now include LOBBY correctly
	}
}


void Menu::ResetVars() {
	MenuItems.optionPress = false;
	MenuItems.optionPressX = false;
	MenuItems.leftPress = false;
	MenuItems.rightPress = false;
}

int Menu::GetOption() {
	if (MenuItems.optionPress)
		return MenuItems.currentOption;
	else
		return 0;
}

Menu::Menu(char* optionText) {
	this->option = optionText;
}

inline Menu Menu::Option() {
	MenuItems.optionCount++;

	if (MenuItems.currentOption == MenuItems.optionCount) {
		DrawShader((menuDef::fMenuPosX + 4.0f), ((menuDef::fMenuPosY + 54.0f) + (MenuItems.optionCount * 22.0f)), (menuDef::fMenuWidth - 7.0f), 20.0f, menuDef::gradientMaterial, 180, colorAccentPrimary_dark);
		DrawShader((menuDef::fMenuPosX + 4.0f), ((menuDef::fMenuPosY + 54.0f) + (MenuItems.optionCount * 22.0f)), (menuDef::fMenuWidth - 7.0f), 20.0f, menuDef::gradientMaterial, 0, secondaryColor_dark);

		DrawShader((menuDef::fMenuPosX + 4.0f), (((menuDef::fMenuPosY + 54.0f) + (MenuItems.optionCount * 22.0f)) + 20.0f), (menuDef::fMenuWidth - 7.0f), 3.0f, menuDef::gradientMaterial, 180, colorAccentPrimary);
		DrawShader((menuDef::fMenuPosX + 4.0f), (((menuDef::fMenuPosY + 54.0f) + (MenuItems.optionCount * 22.0f)) + 20.0f), (menuDef::fMenuWidth - 7.0f), 3.0f, menuDef::gradientMaterial, 0, secondaryColor);
	}

	DrawText(this->option, (menuDef::fMenuPosX + 10.0f), ((menuDef::fMenuPosY + 75.0f) + (MenuItems.optionCount * 22.0f)), menuDef::normalFont, 0.7f, colorWhite);

	return *this;
}

inline Menu Menu::Toggle(BOOL* toChange) {
	this->Option();

	float boxSize = 16.0f;

	DrawShaderWithOutline(((menuDef::fMenuPosX + menuDef::fMenuWidth) - 8.0f) - boxSize, ((menuDef::fMenuPosY + 58.0f) + (MenuItems.optionCount * 22.0f)), boxSize, boxSize, colorBackground, colorSeperator, colorSeperator, 2.0f);

	if (*toChange) {
		DrawShader((((menuDef::fMenuPosX + menuDef::fMenuWidth) - 8.0f) - boxSize) + 3.0f, (((menuDef::fMenuPosY + 58.0f) + (MenuItems.optionCount * 22.0f)) + 3.0f), boxSize - 6, boxSize - 6, menuDef::whiteMaterial, 0, colorAccentPrimary);
	}

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress) {
		*toChange = !*toChange;
	}

	return *this;
}

template<typename T>
inline Menu Menu::Editor(T* toEdit, T increments, T min, T max) {
	this->Option();

	sprintf(this->temp, "%.0f", *toEdit);

	float sliderWidth = 100.0f;
	float sliderHeight = 6.5f;

	float fBarWidth = sliderWidth * ((*toEdit - (min)) / ((max)-(min)));

	DrawShader(((menuDef::fMenuPosX + menuDef::fMenuWidth) - 8.0f) - sliderWidth, ((menuDef::fMenuPosY + 61.0f) + (MenuItems.optionCount * 22.0f)), sliderWidth, sliderHeight, menuDef::whiteMaterial, 0, colorSeperator);
	DrawShader((((menuDef::fMenuPosX + menuDef::fMenuWidth) - 8.0f) - sliderWidth) + 2.0f, (((menuDef::fMenuPosY + 61.0f) + (MenuItems.optionCount * 22.0f)) + 2.0f), sliderWidth - 4, sliderHeight - 4, menuDef::whiteMaterial, 0, colorBackground);

	DrawShader((((menuDef::fMenuPosX + menuDef::fMenuWidth) - 8.0f) - sliderWidth) + 2.0f, (((menuDef::fMenuPosY + 61.0f) + (MenuItems.optionCount * 22.0f)) + 2.0f), fBarWidth - 4, sliderHeight - 4, menuDef::whiteMaterial, 0, colorAccentPrimary);

	DrawShader((((menuDef::fMenuPosX + menuDef::fMenuWidth) - 10.0f) - sliderWidth) + fBarWidth, (((menuDef::fMenuPosY + 61.0f) + (MenuItems.optionCount * 22.0f)) - 1.0f), 4.0f, sliderHeight + 3, menuDef::whiteMaterial, 0, colorBackground);
	DrawShader(((((menuDef::fMenuPosX + menuDef::fMenuWidth) - 10.0f) - sliderWidth) + fBarWidth) + 1.0f, (((menuDef::fMenuPosY + 61.0f) + (MenuItems.optionCount * 22.0f))), 2.0f, sliderHeight + 1, menuDef::whiteMaterial, 0, colorWhite);


	float fCurrentTextLength = (R_TextWidth(0, this->temp, 0x7FFFFFFF, menuDef::normalFont) * 0.7f);

	DrawText(this->temp, (((menuDef::fMenuPosX + menuDef::fMenuWidth) - 12.0f) - sliderWidth) - fCurrentTextLength, ((menuDef::fMenuPosY + 75.0f) + (MenuItems.optionCount * 22.0f)), menuDef::normalFont, 0.7f, colorWhite);

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.leftPress) {
		*toEdit -= increments;
		if (*toEdit < min)
			*toEdit = max;
	}

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.rightPress) {
		*toEdit += increments;
		if (*toEdit > max)
			*toEdit = min;
	}

	return *this;
}

template<typename T>
inline Menu Menu::ArrayEditor(T arr, int size, int* identifier) {
	this->Option();

	sprintf(this->temp, "%s", arr);

	FLOAT currentArrayLength = (R_TextWidth(0, this->temp, 0x7FFFFFFF, menuDef::normalFont) * 0.7f);

	DrawText(this->temp, ((menuDef::fMenuPosX + menuDef::fMenuWidth) - 10.0f) - currentArrayLength, ((menuDef::fMenuPosY + 75.0f) + (MenuItems.optionCount * 22.0f)), menuDef::normalFont, 0.7f, colorWhite);

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.leftPress) {
		*identifier -= 1;
		if (*identifier < 0)
			*identifier = (size - 1);
	}

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.rightPress) {
		*identifier += 1;
		if (*identifier > (size - 1))
			*identifier = 0;
	}

	return *this;
}

inline Menu Menu::Submenu(int submenu) {
	this->Option();

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress) {
		MenuItems.lastSubmenu[MenuItems.submenuLevel] = MenuItems.submenu;
		MenuItems.lastOption[MenuItems.submenuLevel] = MenuItems.currentOption;
		MenuItems.currentOption = 1;
		MenuItems.submenu = submenu;
		MenuItems.submenuLevel++;
	}
	return *this;
}

inline Menu Menu::PlayerSubmenu(int submenu) {
	this->Option();

	int tempSelectedClientNum = (MenuItems.currentOption - 1);

	if (partyMember[tempSelectedClientNum].XUID != 0 && partyMember[tempSelectedClientNum].gamertag[0] != NULL) {
		IN_ADDR onlineIP = partyMember[tempSelectedClientNum].onlineIP;

		//Draw outline
		DrawShaderWithOutline(menuDef::fMenuPosX, (menuDef::fMenuPosY + ((menuOptions * 22.0f) + 81.0f)), menuDef::fMenuWidth, (2 * 22.0f) + 8.0f, colorBackground, colorAccentPrimary, secondaryColor, 2);

		DrawText("IP Address:", (menuDef::fMenuPosX + 10.0f), ((menuDef::fMenuPosY + ((menuOptions * 22.0f) + 81.0f)) + (1 * 22.0f)) + 3.0f, menuDef::normalFont, 0.7f, colorWhite);
		DrawString(va("%i.%i.%i.%i", onlineIP.S_un.S_un_b.s_b1, onlineIP.S_un.S_un_b.s_b2, onlineIP.S_un.S_un_b.s_b3, onlineIP.S_un.S_un_b.s_b4), ((menuDef::fMenuPosX + menuDef::fMenuWidth) - 10.0f), ((menuDef::fMenuPosY + ((menuOptions * 22.0f) + 81.0f)) + (1 * 22.0f)) + 3.0f, menuDef::normalFont, 0.7f, colorWhite, JustifyRight);

		DrawText("XUID:", (menuDef::fMenuPosX + 10.0f), ((menuDef::fMenuPosY + ((menuOptions * 22.0f) + 81.0f)) + (2 * 22.0f)) + 3.0f, menuDef::normalFont, 0.7f, colorWhite);
		DrawString(va("000%llX", partyMember[tempSelectedClientNum].XUID), ((menuDef::fMenuPosX + menuDef::fMenuWidth) - 10.0f), ((menuDef::fMenuPosY + ((menuOptions * 22.0f) + 81.0f)) + (2 * 22.0f)) + 3.0f, menuDef::normalFont, 0.7f, colorWhite, JustifyRight);
	}

	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress) {
		MenuItems.lastSubmenu[MenuItems.submenuLevel] = MenuItems.submenu;
		MenuItems.lastOption[MenuItems.submenuLevel] = MenuItems.currentOption;
		SelectedPlayer = (MenuItems.currentOption - 1);
		MenuItems.currentOption = 1;
		MenuItems.submenu = submenu;
		MenuItems.submenuLevel++;
	}
	return *this;
}

template<typename T>
inline Menu Menu::Callback(T function) {
	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress)
		function();
	return *this;
}

template<typename T, typename A>
inline Menu Menu::Callback(T function, A a) {
	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress)
		function(a);
	return *this;
}

template<typename T, typename A, typename B>
inline Menu Menu::Callback(T function, A a, B b) {
	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress)
		function(a, b);
	return *this;
}

template<typename T, typename A, typename B, typename C>
inline Menu Menu::Callback(T function, A a, B b, C c) {
	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress)
		function(a, b, c);
	return *this;
}

inline Menu Menu::ChangeBoolean(BOOL* toChange, BOOL value) {
	if (MenuItems.currentOption == MenuItems.optionCount && MenuItems.optionPress)
		*toChange = value;
	return *this;
}

void HandleInput() {
	XInputGetState(0, &menuDef::state);
	short button = menuDef::state.Gamepad.wButtons;

	if (!buttonFinished)
	{
		if (button & XINPUT_GAMEPAD_DPAD_LEFT && menuDef::state.Gamepad.bLeftTrigger >= 100) {
			menuDef::bMenuOpen = !menuDef::bMenuOpen;

			if (menuDef::bMenuOpen) {
				// Menu opening
				openAnimation = 0.0f; // ✅ Only reset when opening
				MenuItems.lastSubmenu[MenuItems.submenuLevel] = MenuItems.submenu;
				MenuItems.lastOption[MenuItems.submenuLevel] = MenuItems.currentOption;
				MenuItems.currentOption = 1;
				MenuItems.submenu = MAIN;
				MenuItems.submenuLevel = 0;
			}
			// ❌ REMOVE openAnimation reset when closing!!

			buttonFinished = true;
		}

		if (button != 0 && menuDef::bMenuOpen) {
			if (button & XINPUT_GAMEPAD_A) {
				MenuItems.optionPress = true;
			}
			else if (button & XINPUT_GAMEPAD_B) {
				if (MenuItems.submenu > MAIN) {
					MenuItems.submenu = MenuItems.lastSubmenu[MenuItems.submenuLevel - 1];
					MenuItems.currentOption = MenuItems.lastOption[MenuItems.submenuLevel - 1];
					MenuItems.submenuLevel--;
				}
			}
			else if (button & XINPUT_GAMEPAD_X) {
				MenuItems.optionPressX = true;
			}
			else if (button & XINPUT_GAMEPAD_DPAD_LEFT) {
				MenuItems.leftPress = true;
			}
			else if (button & XINPUT_GAMEPAD_DPAD_RIGHT) {
				MenuItems.rightPress = true;
			}
			else if (button & XINPUT_GAMEPAD_DPAD_UP) {
				MenuItems.currentOption--;
				MenuItems.currentOption = MenuItems.currentOption < 1 ? MenuItems.optionCount : MenuItems.currentOption;
			}
			else if (button & XINPUT_GAMEPAD_DPAD_DOWN) {
				MenuItems.currentOption++;
				MenuItems.currentOption = MenuItems.currentOption > MenuItems.optionCount ? 1 : MenuItems.currentOption;
			}
			if (!buttonFinished) {
				if (button & XINPUT_GAMEPAD_LEFT_SHOULDER) {
					MenuItems.submenu--; // Move one tab to the left
					if (MenuItems.submenu < 0) {
						MenuItems.submenu = 5; // Wrap to the last tab (Lobby)
					}
					printf("LEFT Shoulder: Submenu index = %d\n", MenuItems.submenu); // Debugging output
					buttonFinished = true;
				}
			}

			if (button == 0 && buttonFinished) {
				buttonFinished = false; // Reset the button lock
			}

			buttonFinished = true;
		}
	}

	if (button == 0 && buttonFinished) {
		buttonFinished = false;
	}
}

BOOL bTest = FALSE;

float fDamage = 0.0f;

// Simple rainbow color generator based on time
color GetRainbowColor(float speed = 0.001f, float alpha = 1.0f, float phaseOffset = 0.0f) {
	float frequency = speed;
	DWORD time = GetTickCount();

	color c;
	c.r = sin(frequency * time + phaseOffset + 0.0f) * 0.5f + 0.5f;
	c.g = sin(frequency * time + phaseOffset + 2.0f) * 0.5f + 0.5f;
	c.b = sin(frequency * time + phaseOffset + 4.0f) * 0.5f + 0.5f;
	c.a = alpha;

	return c;
}


void RenderMenu() {
	static bool particlesInitialized = false;
	static Particle particles[30]; // Particle array
	static bool bReadyToNotify = true;  // To ensure the notification happens only once

	// Check if it's ready to notify
	if (bReadyToNotify) {
		// Replace with your actual notify function
		Utilities::Notify("Welcome! - Protection's Loaded & Hook's Patched!");
		Utilities::Notify("Hello, I Am Developer Build! By - @HuluStreams");
		Utilities::Notify("Sucessfully Opened!");

		bReadyToNotify = false;  // Set to false to ensure it only runs once
	}

	// Initialize particles
	if (!particlesInitialized) {
		for (int i = 0; i < 30; i++) {
			particles[i].x = rand() % 1280;            // Random X position
			particles[i].y = rand() % 720;             // Random Y position
			particles[i].speedY = (rand() % 10 + 1) * 0.05f;  // Random speed
			particles[i].alpha = ((rand() % 50) + 50) / 100.0f; // Random alpha value
		}
		particlesInitialized = true;
	}

	// Menu height and position adjustments
	float menuHeight = (menuOptions * 22.0f) + 81.0f;
	menuDef::fMenuPosX = (menuDef::dwScreenCenterX - (menuDef::fMenuWidth / 2));
	menuDef::fMenuPosY = (menuDef::dwScreenCenterY - (menuHeight / 2)) + 100.0f; // Increased Y offset to move menu down

	// Animate opening and closing (smooth animation for slide, scale, and fade)
	if (menuDef::bMenuOpen && openAnimation < 1.0f)
		openAnimation += 0.02f; // Opening speed
	else if (!menuDef::bMenuOpen && openAnimation > 0.0f)
		openAnimation -= 0.08f; // Closing (fade out) speed

	openAnimation = max(0.0f, min(1.0f, openAnimation)); // Clamp

	// Stop rendering once fully faded out
	if (openAnimation <= 0.0f)
		return;

	// Background blur effect (simulate blur)
	color backgroundFade;
	backgroundFade.r = 0.0f;
	backgroundFade.g = 0.0f;
	backgroundFade.b = 0.0f;
	backgroundFade.a = 0.3f * openAnimation; // Adjust alpha for the fade effect
	DrawShader(0, 0, 1280, 720, menuDef::whiteMaterial, 0, backgroundFade);

	// Floating particles effect (clean, modern look)
	for (int i = 0; i < 30; i++) {
		particles[i].y -= particles[i].speedY;
		if (particles[i].y < 0) particles[i].y = 720;

		color particleColor;
		particleColor.r = 1.0f;
		particleColor.g = 1.0f;
		particleColor.b = 1.0f;
		particleColor.a = particles[i].alpha * openAnimation;
		DrawShader(particles[i].x, particles[i].y, 2.0f, 2.0f, menuDef::whiteMaterial, 0, particleColor);
	}

	// Dynamic rainbow colors for accent
	color accentColor = MenuOptions::bRainbowEffect
		? GetRainbowColor(0.001f, 1.0f, 0.0f)  // Primary accent
		: colorAccentPrimary;

	color secondaryColor = MenuOptions::bRainbowEffect
		? GetRainbowColor(0.001f, 1.0f, 3.14f)  // Secondary accent
		: secondaryColor;

	// Slide + Scale + Fade effects
	float scale = 0.8f + (0.2f * openAnimation); // Scale the menu
	float slideOffset = (1.0f - openAnimation) * 100.0f; // Slide effect (move menu downwards during opening)

	// Menu outline with gradient effect
	DrawShaderWithOutline(menuDef::fMenuPosX, menuDef::fMenuPosY * openAnimation + slideOffset, menuDef::fMenuWidth * scale, (menuHeight * openAnimation) * scale, colorBackground, accentColor, secondaryColor, 2);

	// Draw separators with gradient effect
	DrawShader((menuDef::fMenuPosX + 2.0f), (menuDef::fMenuPosY + 38.0f) * openAnimation + slideOffset, (menuDef::fMenuWidth - 3.0f), 2, menuDef::whiteMaterial, 0, GetRainbowColor(0.0015f, 1.0f));
	DrawShader((menuDef::fMenuPosX + 2.0f), (menuDef::fMenuPosY + 72.0f) * openAnimation + slideOffset, (menuDef::fMenuWidth - 3.0f), 2, menuDef::whiteMaterial, 0, GetRainbowColor(0.0015f, 1.0f));

	// Pulsing title effect
	float pulseSpeed = 0.002f;
	float pulseSize = 1.2f + (sinf(GetTickCount() * pulseSpeed) * 0.1f);
	FLOAT textwidth = (R_TextWidth(0, "Developer Build", 0x7FFFFFFF, menuDef::normalFont) / 2) * pulseSize;

	DrawTextWithEffects("Developer Build",
		(menuDef::fMenuPosX + (menuDef::fMenuWidth / 2) - textwidth),
		(menuDef::fMenuPosY + 37.0f) + slideOffset, // Pulse effect with openAnimation
		menuDef::normalFont, pulseSize, colorWhite, secondaryColor);

	// Tab navigation
	char* tabNames[6] = { "Self", "Aimbot", "Visuals", "Clients", "Fun", "Lobby" };
	int tabCount = sizeof(tabNames) / sizeof(tabNames[0]);
	float tabWidth = (menuDef::fMenuWidth - 6.0f) / tabCount;

	for (int i = 0; i < 6; i++) {
		float xPos = menuDef::fMenuPosX + 3.0f + (i * tabWidth);

		if (i == correctSubMenu()) {
			// Highlight the selected tab with rainbow effect
			color whiteColor;
			whiteColor.r = 1.0f;
			whiteColor.g = 1.0f;
			whiteColor.b = 1.0f;
			whiteColor.a = 1.0f;
			DrawShader(xPos, (menuDef::fMenuPosY + 41.0f) * openAnimation + slideOffset, tabWidth - 5.0f, 28.0f * openAnimation, menuDef::whiteMaterial, 0, whiteColor);
			DrawShader(xPos, (menuDef::fMenuPosY + 69.0f) * openAnimation + slideOffset, tabWidth - 5.0f, 3.0f * openAnimation, menuDef::whiteMaterial, 0, whiteColor);
		}

		color tabColor = (i == correctSubMenu())
			? GetRainbowColor(0.0005f, 1.0f)
			: colorWhite;

		DrawCenteredText(tabNames[i], xPos, (menuDef::fMenuPosY + 65.0f) * openAnimation + slideOffset, 0.7f, tabColor, tabWidth);
	}

	MenuItems.optionCount = 0;

	switch (MenuItems.submenu) {
	case MAIN:
		menuOptions = 9;

		Menu("No Clip").Toggle(&MenuOptions::bRME_NoClip).Callback(NoClipToggle);
		Menu("UFO Mode").Toggle(&MenuOptions::bRME_NoClipBind);
		Menu("God Mode Loop").Toggle(&MenuOptions::bRME_GodMode);
		Menu("God Mode").ArrayEditor(RME_Toggle[MenuOptions::dwRME_GodMode], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_GodMode).Callback(ChangeGodMode, -1, (MenuOptions::dwRME_GodMode == 0));
		Menu("Super Speed").ArrayEditor(RME_Toggle[MenuOptions::dwRME_SuperSpeed], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_SuperSpeed).Callback(ChangeSuperSpeed, -1, (MenuOptions::dwRME_SuperSpeed == 0));
		Menu("Invisibility").ArrayEditor(RME_Toggle[MenuOptions::dwRME_Invisibility], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_Invisibility).Callback(ChangeInvisibility, -1, (MenuOptions::dwRME_Invisibility == 0));
		Menu("Infrared Vision").ArrayEditor(RME_Toggle[MenuOptions::dwRME_InfraredVision], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_InfraredVision).Callback(ChangeInfraredVision, -1, (MenuOptions::dwRME_InfraredVision == 0));
		Menu("Set Unlimited Ammo").Option().Callback(SetUnlimitedAmmo, -1);
		Menu("^2~~~ MORE FEATURES IN CLIENTS TAB ~~~").Option().Callback(PlaceHolder, SelectedPlayer);

		break;

	case RME_PAGE_2:
		menuOptions = 10;

		Menu("Start Host Migration").Option().Callback(StartHostMigration);
		Menu("Send Host To Zombies").Option().Callback(SendHostToZombies);
		Menu("Send Host To Campagne").Option().Callback(SendHostToSingleplayer);
		Menu("Set Freeze Classes").Option().Callback(ExecuteTestPayload);
		Menu("Unbind Host Controls").Option().Callback(UnbindHostControls);
		Menu("Give Host - Force Host").Option().Callback(GiveHostForceHost);
		Menu("Crash Host V1").Option().Callback(HostCrash1, SelectedPlayer);
		Menu("Crash Host V2").Option().Callback(HostCrash2, SelectedPlayer);
		Menu("Crash Host V3").Option().Callback(HostCrash3, SelectedPlayer);
		Menu("Crash Host V4").Option().Callback(HostCrash4, SelectedPlayer);

		break;

	case RME_EXTRAS:
		menuOptions = 1;

		Menu("Rainbow Effect").Toggle(&MenuOptions::bRainbowEffect);

		break;

	case RME_ALL_CLIENTS:
		menuOptions = 9;

		Menu("God Mode ON").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_GodMode_ON], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_GodMode_ON).Callback(GodModeEveryone, true, MenuOptions::dwRME_AllClients_GodMode_ON == 0 ? true : false);
		Menu("God Mode OFF").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_GodMode_OFF], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_GodMode_OFF).Callback(GodModeEveryone, false, MenuOptions::dwRME_AllClients_GodMode_OFF == 0 ? true : false);
		Menu("Super Speed ON").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_SuperSpeed_ON], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_SuperSpeed_ON).Callback(SuperSpeedEveryone, true, MenuOptions::dwRME_AllClients_SuperSpeed_ON == 0 ? true : false);
		Menu("Super Speed OFF").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_SuperSpeed_OFF], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_SuperSpeed_OFF).Callback(SuperSpeedEveryone, false, MenuOptions::dwRME_AllClients_SuperSpeed_OFF == 0 ? true : false);
		Menu("Blackscreen").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_Blackscreen], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_Blackscreen).Callback(BlackscreenEveryone, MenuOptions::dwRME_AllClients_Blackscreen == 0 ? true : false);
		Menu("Take Weapons Away").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_TakeWeaponsAway], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_TakeWeaponsAway).Callback(TakeWeaponForEveryone, MenuOptions::dwRME_AllClients_TakeWeaponsAway == 0 ? true : false);
		Menu("Take Ammo Away").ArrayEditor(RME_Teams[MenuOptions::dwRME_AllClients_TakeAmmoAway], ARRAYSIZE(RME_Teams), (int*)&MenuOptions::dwRME_AllClients_TakeAmmoAway).Callback(TakeAmmoAwayAll, MenuOptions::dwRME_AllClients_TakeAmmoAway == 0 ? true : false);
		Menu("Kill All Player").Option().Callback(killallplayer);
		Menu("Fake Derank All").Option().Callback(SetFakeDerankAll);

		break;

	case RME_MENU_RENAME_PRESETS:
		menuOptions = 5;

		Menu("How's that possible non host?").Option().Callback(RenameAll, va("^%i^5How's that possible non host?", rand() % 7));
		Menu("@HuluStreams Discord").Option().Callback(RenameAll, va("^%i^F^1@HuluStreams Was Here!^0!", rand() % 7));
		Menu("xbGuard").Option().Callback(RenameAll, va("^%i^F^1YES IM RUNNING XBGUARD!^0!", rand() % 7));
		Menu("Hulu RCE").Option().Callback(RenameAll, va("^%i^F^5IS THAT RCE?!!^0!", rand() % 7));
		Menu("Set Freezing Name").Option().Callback(RenameAll, "^H");

		break;

	case AIMBOT:
		menuOptions = 10;

		Menu("Aimbot").Toggle(&MenuOptions::bAimbot);
		Menu("Aimbot Type").ArrayEditor(Array_AimbotType[MenuOptions::dwAimbotType], ARRAYSIZE(Array_AimbotType), (int*)&MenuOptions::dwAimbotType);
		Menu("Target Type").ArrayEditor(Array_TargetType[MenuOptions::dwTargetType], ARRAYSIZE(Array_TargetType), (int*)&MenuOptions::dwTargetType);
		Menu("Target Bone").ArrayEditor(Array_TargetBone[MenuOptions::dwTargetBone], ARRAYSIZE(Array_TargetBone), (int*)&MenuOptions::dwTargetBone);
		Menu("No Spread").Toggle(&MenuOptions::bNoSpread);
		Menu("No Sway").Option().Callback(noswayBO2);
		Menu("No Recoil").Option().Callback(norecoilBO2);
		Menu("Auto Shoot").Toggle(&MenuOptions::bAutoShoot);
		Menu("Ping Prediction").Toggle(&MenuOptions::bPingPrediction);
		Menu("Anti Aim").Toggle(&MenuOptions::bAntiAim);

		break;
	case VISUALS:
		menuOptions = 12;

		Menu("Menu Customization").Submenu(RME_EXTRAS);
		Menu("Draw Allies").Toggle(&MenuOptions::bDrawAllies);
		Menu("Draw Axis").Toggle(&MenuOptions::bDrawAxis);
		Menu("Box Type").ArrayEditor(DrawingTypes[MenuOptions::dwBoxType], ARRAYSIZE(DrawingTypes), (int*)&MenuOptions::dwBoxType);
		Menu("Names").Toggle(&MenuOptions::bDrawNames);
		Menu("Distances").Toggle(&MenuOptions::bDrawDistances);
		Menu("Weapons").Toggle(&MenuOptions::bDrawWeapons);
		Menu("Bones").Toggle(&MenuOptions::bDrawBones);
		Menu("Draw Snaplines").Toggle(&MenuOptions::bDrawSnaplines);
		Menu("Small Crosshair").Toggle(&MenuOptions::bSmallCrosshair);
		Menu("Health Bar").Toggle(&MenuOptions::bHealthBar);
		Menu("Advanced UAV").Option().Callback(advanceduavBO2);

		break;
	case CLIENT_LIST:
		menuOptions = 18;

		for (int i = 0; i < 18; i++) {
			if (partyMember[i].XUID == 0 || partyMember[i].gamertag[0] == NULL) {
				Menu("Empty").Option();
			}
			else {
				if (!strcmp(partyMember[i].clanAbbrev, ""))
					Menu(partyMember[i].gamertag).PlayerSubmenu(CLIENT_OPTIONS);
				else
					Menu(va("[%s] %s", partyMember[i].clanAbbrev, partyMember[i].gamertag)).PlayerSubmenu(CLIENT_OPTIONS);
			}
		}
		break;

	case CLIENT_OPTIONS:
		menuOptions = 13;

		Menu("^1~~~ REMOVABLE CLIENT FEATURES ~~~").Option().Callback(PlaceHolder, SelectedPlayer);
		Menu("Add Client To Auto Kick").Option().Callback(AddClientToBlacklist_Kick, SelectedPlayer);
		Menu("Add Client To Auto Ban").Option().Callback(AddClientToBlacklist_Ban, SelectedPlayer);	
		Menu("Kick Player").Option().Callback(KickClient, SelectedPlayer);
		Menu("Ban Player From Lobby").Option().Callback(BanClient, SelectedPlayer);
		Menu("^4~~~ RME CLIENT FEATURES ~~~").Option().Callback(PlaceHolder, SelectedPlayer);
		Menu("God Mode").ArrayEditor(RME_Toggle[MenuOptions::dwRME_Client_GodMode], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_Client_GodMode).Callback(ChangeGodMode, SelectedPlayer, (MenuOptions::dwRME_Client_GodMode == 0));
		Menu("Super Speed").ArrayEditor(RME_Toggle[MenuOptions::dwRME_Client_SuperSpeed], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_Client_SuperSpeed).Callback(ChangeSuperSpeed, SelectedPlayer, (MenuOptions::dwRME_Client_SuperSpeed == 0));
		Menu("Invisibility").ArrayEditor(RME_Toggle[MenuOptions::dwRME_Client_Invisibility], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_Client_Invisibility).Callback(ChangeInvisibility, SelectedPlayer, (MenuOptions::dwRME_Client_Invisibility == 0));
		Menu("Set Unlimited Ammo").Option().Callback(SetUnlimitedAmmo, SelectedPlayer);
		Menu("Give Weapon").ArrayEditor(RME_GiveWeapons[MenuOptions::dwRME_GiveWeaponIndex], ARRAYSIZE(RME_GiveWeapons), (int*)&MenuOptions::dwRME_GiveWeaponIndex).Callback(GiveWeapon, SelectedPlayer, RME_weaponIndexes[MenuOptions::dwRME_GiveWeaponIndex]);
		Menu("^2~~~ PAGE 2 BELOW ~~~").Option().Callback(PlaceHolder, SelectedPlayer);
		Menu("TROLL CLIENT FEATURES ->").Submenu(CLIENT_OPTIONS_PAGE_2);

		break;

	case CLIENT_OPTIONS_PAGE_2:
		menuOptions = 26;
		
		Menu("^7(^2NEW^7) Scoreboard Force").Option().Callback(ForceScoreboardForClient, SelectedPlayer);
		Menu("^7(^2NEW^7) Force HUD").Option().Callback(ShowScoreboardHUD, SelectedPlayer);
		Menu("^7(^2NEW^7) Teleport Foward").Option().Callback(WTF, SelectedPlayer);
		Menu("^7(^2NEW^7) Spam Shoot 30x").Option().Callback(SpamShootBurst, SelectedPlayer, 30);
		Menu("^7(^2NEW^7) REAL God").Option().Callback(FakeSpecMode, SelectedPlayer);
		Menu("^7(^2NEW^7) Turrent Error On Screen").Option().Callback(TurrentTest, SelectedPlayer);
		Menu("^7(^2NEW^7) OMG Whats Over There").Option().Callback(lookingspam, SelectedPlayer, 30);
		Menu("^7(^2NEW^7) Slither Mode!").Option().Callback(pronespam, SelectedPlayer, 30);
		Menu("^7(^2NEW^7) No HUD (Hardcore)").Option().Callback(SetKillstreakVision4, SelectedPlayer);
		Menu("^7(^2NEW^7) Scan 0x14 - 0x1B").Option().Callback(ScanJumpFlagsOnClient, SelectedPlayer);
		Menu("^7(^2NEW^7) Random Teleport").Option().Callback(ScreenShakeOnce, SelectedPlayer, 1000.0f);
		Menu("^7(^2NEW^7) Make Float - (Without Lag)").Option().Callback(FloatClient, SelectedPlayer, 50);
		Menu("^7(^2NEW^7) Send To Sky Barrier").Option().Callback(WalkOnSky, SelectedPlayer);
		Menu("^1~~~ RME TROLLING BELOW ~~~").Option().Callback(PlaceHolder, SelectedPlayer);
		Menu("Freeze Movement ON").Option().Callback(FreezeMovement, SelectedPlayer, true);
		Menu("Freeze Movement OFF").Option().Callback(FreezeMovement, SelectedPlayer, false);
		Menu("Give Max Points").Option().Callback(GivePoints, SelectedPlayer);
		Menu("Kill Player").Option().Callback(KillPlayer, SelectedPlayer);
		Menu("Reload Weapon").Option().Callback(MakeClientReload, SelectedPlayer);
		Menu("Set Dead Screen").Option().Callback(SetSessionState, SelectedPlayer, SESS_STATE_DEAD);
		Menu("Set Spectator Mode").Option().Callback(SetSessionState, SelectedPlayer, SESS_STATE_SPECTATOR);
		Menu("Set Default State").Option().Callback(SetSessionState, SelectedPlayer, SESS_STATE_PLAYING);
		Menu("Make Jump").Option().Callback(MakeClientJump, SelectedPlayer);
		Menu("Shoot One Bullet").Option().Callback(MakeClientShootOnce, SelectedPlayer);
		Menu("^2~~~ PAGE 3 BELOW ~~~").Option().Callback(PlaceHolder, SelectedPlayer);
		Menu("Even More Features ->").Submenu(CLIENT_OPTIONS_PAGE_3);


		break;

	case CLIENT_OPTIONS_PAGE_3:
		menuOptions = 26;

		Menu("^2~~~ Enjoy ^1<3 ^2~~~").Option().Callback(PlaceHolder, SelectedPlayer);
		Menu("Fake Client Death").Option().Callback(FakeClientDeath, SelectedPlayer);
		Menu("Disable Weapon Useability").Option().Callback(DisableWeaponUseability, SelectedPlayer);
		Menu("Take Ammo Away").Option().Callback(TakeAmmoAway, SelectedPlayer);
		Menu("Take Weapon Away").Option().Callback(TakeWeapon, SelectedPlayer);
		Menu("Infrared Vision").ArrayEditor(RME_Toggle[MenuOptions::dwRME_Client_InfraredVision], ARRAYSIZE(RME_Toggle), (int*)&MenuOptions::dwRME_Client_InfraredVision).Callback(ChangeInfraredVision, SelectedPlayer, (MenuOptions::dwRME_Client_InfraredVision == 0));
		Menu("Teleport Player Far Away").Option().Callback(TeleportPlayerFarAway, SelectedPlayer);
		Menu("Teleport Me To Him").Option().Callback(TeleportPlayerToHim, SelectedPlayer);
		Menu("Teleport Player To Me").Option().Callback(TeleportPlayerToMe, SelectedPlayer);
		Menu("Rename Player").Option().ChangeBoolean(&MenuOptions::bRenameSelectedClient, TRUE);
		Menu("Fake Client Death").Option().Callback(FakeClientDeath, SelectedPlayer);
		Menu("3rd Person").Option().Callback(Toggle3rdPerson, SelectedPlayer, true);
		Menu("3rd Person OFF").Option().Callback(Toggle3rdPerson, SelectedPlayer, false);
		Menu("Immobilize").Option().Callback(ClientControlsFuckedV2, SelectedPlayer);
		Menu("Give Streaks").Option().Callback(GiveKillstreaks, SelectedPlayer);
		Menu("No Jumping For You!").Option().Callback(DisableClientJump, SelectedPlayer);
		Menu("No More Running! (N/A)").Option().Callback(DisableClientSprint, SelectedPlayer);
		Menu("Blood Effect On Screen").Option().Callback(SetBloodOnScreen, SelectedPlayer);
		Menu("No Weapon Swapping").Option().Callback(DisableClientYButton, SelectedPlayer);
		Menu("No Lethals/Tacticals").Option().Callback(DisableClientLBRBButton, SelectedPlayer);
		Menu("Lag Switch").Option().Callback(GiveClientLag, SelectedPlayer);
		Menu("Fast Reload Perk!").Option().Callback(GiveFastReload, SelectedPlayer);
		Menu("Vision Change V1").Option().Callback(SetKillstreakVision1, SelectedPlayer);
		Menu("Vision Change V2").Option().Callback(SetKillstreakVision2, SelectedPlayer);
		Menu("Vision Change V3").Option().Callback(SetKillstreakVision3, SelectedPlayer);
		Menu("Vision Change V4").Option().Callback(SetClientEMPVision, SelectedPlayer);

		break;

	case RME_MAPS:
		menuOptions = 4;

		Menu("Map Nuketown").Option().Callback(nuketown);
		Menu("Map Hijacked").Option().Callback(hijacked);
		Menu("Map Aftermath").Option().Callback(la);
		Menu("Map Cargo").Option().Callback(dockside);

		break;

	case SETTINGS:
		menuOptions = 11;

		Menu("Host Troll -> ^2 CLICK HERE").Submenu(RME_PAGE_2);
		Menu("All Clients RME").Submenu(RME_ALL_CLIENTS);
		Menu("Walk On Countdown").Option().Callback(FreezeMovement, -1, false);
		Menu("Set Hear Everyone ON").Option().Callback(SetHearEveryone, true);
		Menu("Teleport All To Me").Option().Callback(TeleportAllPlayers);
		Menu("Make Everyone Throw Nades").Toggle(&MenuOptions::bMakeEveryoneThrowNades);
		Menu("Give Weapon").ArrayEditor(RME_GiveWeapons[MenuOptions::dwGiveWeaponIndex], ARRAYSIZE(RME_GiveWeapons), (int*)&MenuOptions::dwGiveWeaponIndex).Callback(GiveWeapon, -1, RME_weaponIndexes[MenuOptions::dwGiveWeaponIndex]);
		Menu("Custom Rename All Clients").Option().ChangeBoolean(&MenuOptions::bCustomRenameAllClients, TRUE);
		Menu("Rename All Clients Presets").Submenu(RME_MENU_RENAME_PRESETS);
		Menu("Give Max Points").Option().Callback(GivePoints, -1);
		Menu("Quit & Unload").Option().Callback(CheatProtectionHostLeave);

		break;

	case LOBBY:
		menuOptions = 13;

		Menu("Anti Quit").ArrayEditor(RME_AntiQuit[MenuOptions::dwAntiQuitIndex], ARRAYSIZE(RME_AntiQuit), (int*)&MenuOptions::dwAntiQuitIndex).Callback(AntiQuit, MenuOptions::dwAntiQuitIndex == 0 ? true : false);
		Menu("Anti Quit Auto").Toggle(&MenuOptions::bAntiQuitAuto);
		Menu("Leave Game").Option().Callback(LeaveGame);
		Menu("Long Meele").Option().Callback(EnableLongMeele);
		Menu("Flying Bodies").Option().Callback(EnableFlyingBodies);
		Menu("End Game").Option().Callback(EndGame);
		Menu("Crash Server").Option().Callback(CrashServer);
		Menu("Disable DLC").Toggle(&MenuOptions::NeverDLC);
		Menu("Reset Host Stats").Option().Callback(ResetHostStats);
		Menu("Restart Map").Option().Callback(MapRestart);
		Menu("Fast Restart").Option().Callback(FastRestart);
		Menu("Change Maps").Submenu(RME_MAPS);
		Menu("Set Hear Everyone OFF").Option().Callback(SetHearEveryone, false);

		break;
	}
	Menu(NULL).ResetVars();
}

void HandleMenu() {
	HandleInput();

	infoboxCurrentDrawn = 0;
	instructionIndex = 0;

	DrawInfobox("Developer", menuDef::dwScreenMaxX - 40.0f, get_uiContext().y + 20.0f, infoboxCurrentDrawn);
	infoboxCurrentDrawn += 2;

	//DrawInfobox(va("Resolution: %ix%i", menuDef::dwScreenMaxX, menuDef::dwScreenMaxY), menuDef::dwScreenMaxX - 40.0f, get_uiContext().y + 20.0f, infoboxCurrentDrawn);
	//infoboxCurrentDrawn++;

	//DrawInfobox(va("FPS: %.0f", get_uiContext().fps >= 60 ? 60 : get_uiContext().fps), menuDef::dwScreenMaxX - 40.0f, get_uiContext().y + 20.0f, infoboxCurrentDrawn);
	 
	//Instructions
	//DrawInstruction(va("Hold ^BXENONButtontrigL^ & press ^BXENONButtondpadL^ to %s the menu", !menuDef::bMenuOpen ? "^2open^7" : "^1close^7"), 20.0f, 680.0f, menuDef::normalFont, 0.7f, colorWhite, instructionIndex);
	//instructionIndex++;

	//DrawInstruction("Use ^BXENONButtondpadU^ & ^BXENONButtondpadD^ to scroll, ^BXENONButtonA^ to select", 20.0f, 680.0f, menuDef::normalFont, 0.7f, colorWhite, instructionIndex);
	//instructionIndex++;

	//DrawInstruction("Use ^BXENONButtonshoulderL^ or ^BXENONButtonshoulderR^ to switch tabs", 20.0f, 680.0f, menuDef::normalFont, 0.7f, colorWhite, instructionIndex);
	//instructionIndex++;

	if (menuDef::bMenuOpen)
		RenderMenu();
}